<?php

namespace App\Http\Controllers\Admin\Service;

use App\Http\Controllers\Controller as BaseController;
use App\Repository\Service\ServiceCallRepository;
use App\Repository\TaggingConfig\TaggingConfigRepository;
use Illuminate\Http\Request;

// 客服外呼模块
class CallController extends BaseController
{
    private $repoist;

    public function __construct(ServiceCallRepository $repository)
    {
        $this->repoist = $repository;
    }

    public function index(Request $request)
    {
//        $ordersId = $request->get('orders_id');
        $params = $request->all();
        $data = $this->repoist->index($params, $request->get('pageNum'), $request->get('pageSize'));
        if ($data['code'] == 200 && $params['pageNum'] <= 1) {
            $TaggingRepository = new TaggingConfigRepository();
            $data['listTaggingList'] = $TaggingRepository->getTagging();
            $data['callStatusList'] = config('card.serviceCallStatus');
        }
        return $data;
    }

//    推送过来的外呼通话内容接收
    public function updateCallPhoneInfo(Request $request)
    {
        $data = $this->repoist->savePushCallResult($request->all());
        return $data['code'] == 200 ? 'true' : 'false';
    }

//人员报表
    public function peopleReport(Request $request)
    {
        return $this->repoist->peopleReport($request->all());
    }
}
